import hashlib
import hmac
import json
import random
import string
import time

try:
    string_type = basestring
    PYTHON_VERSION = 2
    import urllib
except NameError:
    string_type = str
    PYTHON_VERSION = 3
    import urllib.parse as urllib

def gen_random_string(str_len):
    random_char_list = []
    for _ in range(str_len):
        random_char = random.choice(string.ascii_letters + string.digits)
        random_char_list.append(random_char)

    random_string = ''.join(random_char_list)
    return random_string

def gen_md5(*args):
    return hashlib.md5("".join(args).encode('utf-8')).hexdigest()

def get_timestamp():
    return int(time.time() * 1000)
